package com.ljc.api;

import com.ljc.auth.UserRole;
import com.ljc.interfaces.UserRoleApi;
import com.ljc.mapper.UserRoleMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@DubboService
public class UserRoleApiImpl implements UserRoleApi {
    @Resource
    private UserRoleMapper userRoleMapper;

    /**
     * 根据用户id查用户角色列表
     */
    @Override
    public List<UserRole> getUserRoleByUserId(Long userId) {
        return userRoleMapper.getUserRoleByUserId(userId);
    }

    /**
     * 创建用户角色
     */
    @Override
    public UserRole addUserRole(UserRole userRole) {
        userRole.setCreateTime(new Date());
        userRoleMapper.addUserRole(userRole);
        return userRole;
    }
}
